package com.bluej.redis.message;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Service;

@Service("redisMessageListener")
public class MessageListenerImpl implements MessageListener {
	private static String enCode = "UTF-8";

	public void onMessage(Message message, byte[] pattern) {
		System.out.println("--------接收到message-----------");
		String msg = null;
		String topic = null;
		try {
			msg = new String(message.getBody(), enCode);
			topic = new String(message.getChannel(), enCode);
			System.out.println("topic:"+topic+"\n"+"msg:"+msg);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
